Repository navigation
fix(power-guard): reap stalled inhibitor child off the sampling loop (#8183) - #8188
Conversation
…8183) release() waited synchronously through wait(5s) + kill + wait(5s), so a stalled systemd-inhibit child blocked the sampling loop for up to ~10s and delayed a confirmed emergency sleep (CodeRabbit finding on #8025, issue #8183). - Live child: short REAP_GRACE wait inline; on timeout the kill-escalation reap finishes on a background thread while sampling continues. Timeout/kill safeguards preserved. - A release is never silently believed: the background reap logs the exit, or logs UNCONFIRMED when the child survives escalation. - held/engage account for an in-flight reap (no stacked inhibitor, lock not reported released while the child runs). - Confirmed-sleep path: main() starts the release when the state confirms, keeps sampling, and issues the sleep command only once the release has settled. - Regression test: a fake child that ignores terminate/kill exercises the non-blocking reap path in test_power_guard.py (14 tests pass).
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
88d1022
into
fix/6534-power-guard-dead-child
Fixes the CodeRabbit finding filed as #8183 on this PR's head branch:
Inhibitor._reap()/release()waited synchronously (wait 5s, kill, wait 5s), so reaping a stalledsystemd-inhibitchild blocked the sampling loop for up to ~10s and delayed a confirmed emergency sleep.This PR targets
fix/6534-power-guard-dead-child(PR #8025's branch) because_reapexists only there — it is not onmainyet. Merging this PR lands the fix on #8025 directly; no competing PR againstmainwas created.Changes (
nixos/services/power-guard/power-guard.py)REAP_GRACE = 0.5s); on timeout the kill-escalation reap finishes on a background thread while sampling continues. The existing timeout/kill safeguards are preserved in_finish_reap.INHIBIT release UNCONFIRMEDloudly when the child survives escalation.held/engage()account for an in-flight reap: no second inhibitor is stacked and the lock is not reported released while the child still runs.main(): the release starts when the sustained state confirms, sampling keeps running, and the sleep command is issued only once the release has settled (reap_settled()).Tests
test_power_guard.py:FakeStalledProcignores terminate/kill; the test assertsrelease()returns unsettled in <2s, the lock staysheld, sampling-side polling continues, kill escalation runs in the background, and the unconfirmed release is logged loudly.python3 -m unittest test_power_guard— 14 tests, OK (including the daemon subprocess scenarios and the power-guard: a dead systemd-inhibit child is never noticed — held stays true forever, engage() is a no-op, and the machine is silently unguarded #6534 dead-child tests).Queue: task 14655, lane code-w.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.